package com.gxa.controller.monthgoals;

import com.gxa.common.JsonResult;
import com.gxa.common.R;
import com.gxa.pojo.Monthly_Goals;
import com.gxa.pojo.goalPojo.GoalPojo;
import com.gxa.pojo.goalPojo.KeyWord;
import com.gxa.service.MonthGoalService;
import com.gxa.utils.DateUtils;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/activityQuery")
@Api(value = "月度目标信息总览页面",tags = "月度目标信息总览页面接口API")
public class activitySearch {

    @Autowired
    private MonthGoalService monthGoalService;

    @RequestMapping(value = "/queryActivity",method = RequestMethod.POST)
    @ApiOperation(value = "月度目标信息",notes = "月度目标信息接口",httpMethod = "POST", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",required = true,dataType = "String",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public JsonResult activitySearch(@RequestBody @RequestParam("currentPage") Integer currentPage, @RequestParam("pageSize") Integer pageSize){
        System.out.println(currentPage+"   "+pageSize);
//        R r=new R();
//        GoalPojo goalPojo=new GoalPojo();
//        Monthly_Goals mg=new Monthly_Goals();
//        goalPojo.setMonthly_Goals_Id(1);
//        goalPojo.setEmp_name("管理员");
//        goalPojo.setTitle("nihao");
//        goalPojo.setEntry_Date(DateUtils.getCurrentTime("yyyy-MM-dd HH:mm:ss"));
//        goalPojo.setAllPage(20);
//        r.setCode(200);
//        r.setMsg("success");
//        r.setData(mg);
        return monthGoalService.queryActivitys(currentPage,pageSize);
    }
    @RequestMapping(value = "/editActivityQuery",method = RequestMethod.POST)
    @ApiOperation(value = "编辑月度信息页面回显",notes = "编辑月度信息页面回接口",httpMethod = "POST", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "title",value = "标题",required = true, dataType = "String",paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R activityEditQuery(String title){
        return monthGoalService.editActivityQuery(title);
    }
    @RequestMapping(value = "/editActivity",method = RequestMethod.POST)
    @ApiOperation(value = "编辑月度信息",notes = "编辑月度信息接口",httpMethod = "POST", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R activityEdit(@RequestBody GoalPojo goalPojo){
        return monthGoalService.editActivity(goalPojo);
    }
    @RequestMapping(value = "/goalWordSelect",method = RequestMethod.POST)
    @ApiOperation(value = "关键词搜索",notes = "传递字符串",httpMethod = "POST", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "keyWord",value = "关键词",required = true,dataType = "String",paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public JsonResult select_Word(@RequestBody KeyWord keyWord){
        System.out.println(keyWord.getKeyWord()+"呵呵哈哈哈或");
        return monthGoalService.goalWordSelect(keyWord.getKeyWord(),keyWord.getCurrentPage(),keyWord.getPageSize());
    }

    @RequestMapping(value = "/deleteActivity",method = RequestMethod.POST)
    @ApiOperation(value = "删除月度目标信息",notes = "删除月度目标信息接口",httpMethod = "POST", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "title",value = "标题",required = true, dataType = "String",paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public JsonResult activityDelete(@RequestBody GoalPojo goalPojo){
        System.out.println(goalPojo.getTitle());
        return monthGoalService.deleteActivity(goalPojo.getTitle());
    }


}
